Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PHPTal parsing and MySQL storage #1

Open
wants to merge 2 commits into
base: 0.1
Choose a base branch
from

Conversation

MrHash
Copy link

@MrHash MrHash commented Oct 13, 2012

GrammatistaStoragePdo is now abstract so existing scripts should switch to GrammatistaStorageSQLite.

PHPTal parsing requires post parse transformations for quote handling.

@dzuelke
Copy link
Owner

dzuelke commented Oct 13, 2012

First, the storage stuff seems counter-intuitive; we'd have to add an implementation for each backend supported by PDO, so that needs fixing.

Second, since TAL templates must be valid XML, we shouldn't parse them using regular expressions, but use DOM instead.

@MrHash
Copy link
Author

MrHash commented Oct 14, 2012

Unfortunately the PDO execute query API varies slightly between Sqlite and Mysql hence the need for the extra handlers.

Also regarding the tal, php can also be executed within the content of an element so it would need some pcre patterns anyway.

Thus the implementation I made seemed to be sufficient although perhaps not optimal.

@MrHash
Copy link
Author

MrHash commented Oct 14, 2012

This modification was done some time ago so having taken another look it seems that there was perhaps a bug in the use of executeQuery() instead of query() for initialisation queries on the PDO connection. So actually all the Mysql support could be handled just by making the table construction commands configurable.

@dzuelke
Copy link
Owner

dzuelke commented Oct 14, 2012

Go for it :p

@dzuelke
Copy link
Owner

dzuelke commented Oct 14, 2012

I realize PHP can be executed inside, but that's not a reason not to parse the overall stuff properly :)

@MrHash
Copy link
Author

MrHash commented Oct 14, 2012

My main concern with using the PHP DOM is the poor character set handling. It always represents internally as UTF-8 which will cause issues with content in other character sets such as EUC-JP. :(

@dzuelke
Copy link
Owner

dzuelke commented Jan 31, 2014

That's not poor handling, @MrHash, but in line with the DOM specification :) It always converts to UTF-8. That's what makes DOM portable - no matter what encoding your document is in, the content is represented in Unicode's UTF-8 encoding, so you don't have to figure out how to convert things anymore. It's supposed to be like that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants